<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
	<fmt:setLocale value="zh_TW" scope="session" />
	<c:if test="${not empty lang }">
		<fmt:setLocale value="${lang }" scope="session" />
	</c:if>
	<fmt:bundle basename="i18n">
		<div class="top-con">
			<div class="logo">
				<span><img src="images/logo.png"></span><span class="font"><fmt:message
						key="userCenter"></fmt:message></span>
			</div>
			<div class="languge">
				<div class="current-lan">
					<fmt:message key="current"></fmt:message>
				</div>
				<div class="current-lang">
					<fmt:message key="currentLang"></fmt:message>
				</div>
				<ul id="multiLang">
					<li onClick="changLanguage(this)" value="en_US">English</li>
					<li onClick="changLanguage(this)" value="zh_TW">繁體中文</li>
					<li onClick="changLanguage(this)" value="zh_CN">简体中文</li>
				</ul>
			</div>
		</div>
	</fmt:bundle>

	<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
	<script type="text/javascript">
	
		/*dom载入检查session是否有设定语言，没有则使用默认的繁体中文 */
		$(document).ready(function(){
			var currentLang="<%=session.getAttribute("lang")%>";
			if (currentLang != null) {
				/*alert("onready:"+currentLang);*/
				$("#langSelect").val(currentLang);
			} else {
				$("#langSelect").val("zh_TW");
			}
		});
		
		/*切换语言的onclick  */
		function changLanguage(obj) {
			var lang = obj.getAttribute("value");
			var url = "switchLanguage?lang=" + lang;
			$.ajax({
				type : "GET",
				url : url,
				success : function(data) {
					location.reload();
				},
				error : function(err) {
					alert(err.responseText);
				},
			});
		}
	</script>
</body>
</html>